# Maintainer: David Runge <dvzrv@archlinux.org>

_name=cytoolz
pkgname=python-cytoolz
pkgver=0.12.2
pkgrel=2
pkgdesc="Cython implementation of Toolz: High performance functional utilities"
arch=(loong64 x86_64)
url="https://github.com/pytoolz/cytoolz/"
license=(BSD-3-Clause)
depends=(
  glibc
  python
  python-toolz
)
makedepends=(
  cython
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('5c60325b080fc0712cc6fc20ff45b5bcb50d8bba74ebe5e1cdc469d5bdcefabe2c0a2af5269ee9226a55e919d28f43b4810b7bd274badb7507882837ba4fd34f')
b2sums=('7dd951de72e88c985a9da71ddfce825dc1b8595ab645dc3bbf42447d5fa83a16598ead0e1188198e209d2fe4cd9e793538c7f04b98f0fd7ed16acd5dd1805581')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv test_dir/$_site_packages
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -frv "$pkgdir/$_site_packages/$_name/tests"
}
